package cn.hh.ymcc.feign;

import cn.hh.ymcc.doc.CourseDoc;
import cn.hh.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component // 交给容器
public class CourseSearchFeignClientFallBackFactory implements FallbackFactory<CourseSearchFeignClient> {


    @Override
    public CourseSearchFeignClient create(Throwable throwable) {
        return new CourseSearchFeignClient() {
            // 降级方法
            @Override
            public JSONResult saveCourse(CourseDoc doc) {
                throwable.printStackTrace();
                return  JSONResult.error("搜索服务不可用!熔断降级!!");
            }

            @Override
            public JSONResult deleteByIdCourse(Long courseId) {
                throwable.printStackTrace();
                return JSONResult.error("搜索服务不可用!熔断降级!!");
            }
        };
    }



}
